import {NgModule} from '@angular/core';
import {Routes, RouterModule} from '@angular/router';
import {IndexComponent} from './components/router/index/index.component';
import {CenterComponent} from './components/router/center/center.component';
import {DetailComponent} from './components/router/detail/detail.component';
import {Detail2Component} from './components/router/detail2/detail2.component';
import {Detail3Component} from './components/router/detail3/detail3.component';
import {Child1Component} from './components/router/child1/child1.component';
import {Child2Component} from './components/router/child2/child2.component';


const routes: Routes = [
  {
    path: 'index', component: IndexComponent
  },
  {
    path: 'center', component: CenterComponent
  },
  {
    path: 'detail', component: DetailComponent,
    children: [{
      path: 'child1', component: Child1Component
    }, {
      path: 'child2', component: Child2Component
    }]
  },
  {
    path: 'detail2/:id', component: Detail2Component  // 动态路由
  },
  {
    path: 'detail3', component: Detail3Component  // js跳转路由
  },
  {
    path: 'system', loadChildren: './module/system/system.module#SystemModule'
  },
  {
    path: '**', redirectTo: 'index'  //匹配不到路由加载的组件 ,默认路由
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {
}
